package com.google.code.mergeinformer.service.impl;

import com.google.code.mergeinformer.service.AuthorService;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * @author Dmitry Golubev
 */
@Service
public class AuthorServiceImpl implements AuthorService {

    @PersistenceContext
    private EntityManager em;

    @Override
    public Set<String> getAllAuthors() {
        return Collections.unmodifiableSet(new HashSet<>(em.createNamedQuery("Revision.allAuthors", String.class).getResultList()));
    }
}
